iris-hostgl: an accumulation buffer, and packed pixel types with their standard numbers - #175
Merged
Merged
Conversation
IRIX 6.5.22's <GL/gl.h> numbers UNSIGNED_BYTE_2_3_3_REV 0x8362 and UNSIGNED_SHORT_5_6_5 0x8363, as OpenGL 1.2 does; earlier 6.5 headers (6.5.7's among them) had the two the other way round, and the host swapped them back. Programs and the guest libraries are built against 6.5.22 now, so the numbers go to the host as they come. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every drawable is a framebuffer object, and OpenGL attaches an accumulation buffer only to the window system's framebuffer: glAccum on the host did nothing. IRIX programs use it for jittered antialiasing, motion blur and depth of field, and IRIS GL's acbuf is the same operation. accum.rs keeps one per drawable instead: a pair of RGBA32F textures the drawable's size. Each operation is one pass of a small shader, new = old*a + colour*b + c, into the other texture of the pair (no float blending needed, which not every GPU has); GL_RETURN draws old*value into the drawable, clamped by its fixed-point storage. Every pass honours the scissor box, GL_RETURN the colour mask and draw buffer, and the program's state is saved around each pass and put back. glAccum, glClearAccum and glClear's GL_ACCUM_BUFFER_BIT go to it; GL_ACCUM_*_BITS answer 16 and GL_ACCUM_CLEAR_VALUE the value set. The executor now knows the drawable drawn into as well as the one read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two host GL gaps, both found by the IRIX GL test suite in iris-guest-tools:
glAccumdoes nothing. Every guest drawable is a framebuffer object on the host, and OpenGL gives an accumulation buffer only to the window system's framebuffer, so there is none to accumulate into. IRIX programs use it for jittered antialiasing, motion blur and depth of field, and IRIS GL'sacbufis the same operation.GL_UNSIGNED_SHORT_5_6_5andGL_UNSIGNED_BYTE_2_3_3_REVcome out swapped. The host swapped the two because IRIX 6.5.7's<GL/gl.h>numbers them the wrong way round. IRIX 6.5.22's header numbers them as OpenGL 1.2 does (2_3_3_REV=0x8362,5_6_5=0x8363), and programs and the guest libraries are built against it, so the swap now breaks them.Fix
Accumulation buffer (
iris-hostgl/src/accum.rs): one per drawable, a pair of RGBA32F textures the drawable's size.new = old*a + colour*b + c, into the other texture of the pair, so no float blending is needed (not every GPU has it).GL_RETURNdrawsold*valueinto the drawable, clamped by its fixed-point storage.GL_RETURNalso honours the colour mask and draw buffer. The program's GL state is saved around each pass and put back.glAccum,glClearAccumandglClear'sGL_ACCUM_BUFFER_BITgo to it;GL_ACCUM_*_BITSanswer 16 andGL_ACCUM_CLEAR_VALUEthe value set. The executor now knows the drawable drawn into as well as the one read.Packed pixel types: the swap is gone; the numbers go to the host as they come.
Compatibility: a program compiled against a 6.5.7-era header that uses either of those two packed types would now get them the other way round. Current IRIX (6.5.22) headers and the guest libraries use the standard numbers.
Testing
cargo test --manifest-path iris-hostgl/Cargo.toml: 27 passed, including the newaccumulation_buffer_operationsandpacked_5_6_5_and_2_3_3_rev_keep_their_meaning.calls.rsregenerates unchanged fromtools/glshim.py.cargo build --release --features hostgl,jitv2,tcache.gltest166/166 on n32 and o32 (including glAccum and the 5_6_5, 2_3_3_REV and 8_8_8_8_REV draw/read checks, which fail without this),irisgltestall ok,glcheckPASSED.🤖 Generated with Claude Code